package com.dtdream.principle.inversion.improve;

/**
 * 依赖倒置原则
 *
 * @Author: yewj
 **/
public class DependencyInversion {
    public static void main(String[] args) {
        Person person = new Person();
        person.receive(new Email());
        person.receive(new WeiXin());
    }
}

interface IReceive {
    String getInfo();
}

class Email implements IReceive {
    @Override
    public String getInfo() {
        return "电子邮件信息：hello world!";
    }
}

class WeiXin implements IReceive {

    @Override
    public String getInfo() {
        return "hello weixin!";
    }
}

class Person {
    public void receive(IReceive receive) {
        System.out.println(receive.getInfo());
    }
}
